40823148cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • stage1
    • stage1工作內容
    • stage1後記
  • stage2
    • stage2工作內容
    • stage2後記
  • stage3
    • stage3工作內容
    • stage3後記
  • 個人作業
    • SSH
    • 機械手臂控制
      • Lua程式控制
      • Lua鍵盤控制
      • python remote api
    • stage1四驅車延伸
      • 鍵盤控制
      • python remote api 控制
  • 使用軟體
鍵盤控制 << Previous Next >> 使用軟體

python remote api 控制

使用 python remote api 外部控制車子啟動

python程式碼▼

import sim as vrep
import sys
# child threaded script: 
#simExtRemoteApiStart(19999)
 
vrep.simxFinish(-1)
 
clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
 
if clientID!= -1:
    print("Connected to remote server")
else:
    print('Connection not successful')
    sys.exit('Could not connect')
 
errorCode,joint=vrep.simxGetObjectHandle(clientID,'input',vrep.simx_opmode_oneshot_wait)
 

 
if errorCode == -1:
    print('Can not find left or right motor')
    sys.exit()
 
errorCode=vrep.simxSetJointTargetVelocity(clientID,joint,-270, vrep.simx_opmode_oneshot_wait)



成果影片▼


鍵盤控制 << Previous Next >> 使用軟體

Copyright © All rights reserved | This template is made with by Colorlib